package com.masterrabbit.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.masterrabbit.common.log.annotation.Log;
import com.masterrabbit.common.log.enums.BusinessType;
import com.masterrabbit.common.security.annotation.RequiresPermissions;
import com.masterrabbit.domain.MerchantReviews;
import com.masterrabbit.service.IMerchantReviewsService;
import com.masterrabbit.common.core.web.controller.BaseController;
import com.masterrabbit.common.core.web.domain.AjaxResult;
import com.masterrabbit.common.core.utils.poi.ExcelUtil;
import com.masterrabbit.common.core.web.page.TableDataInfo;

/**
 * 商户信息审核Controller
 * 
 * @author ruoyi
 * @date 2025-03-19
 */
@RestController
@RequestMapping("/merchantreviews")
public class MerchantReviewsController extends BaseController
{
    @Autowired
    private IMerchantReviewsService merchantReviewsService;

    /**
     * 查询商户信息审核列表
     */
    @RequiresPermissions("masterrabbit-kaixuan:merchantreviews:list")
    @GetMapping("/list")
    public TableDataInfo list(MerchantReviews merchantReviews)
    {
        startPage();
        List<MerchantReviews> list = merchantReviewsService.selectMerchantReviewsList(merchantReviews);
        return getDataTable(list);
    }

    /**
     * 导出商户信息审核列表
     */
    @RequiresPermissions("masterrabbit-kaixuan:merchantreviews:export")
    @Log(title = "商户信息审核", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MerchantReviews merchantReviews)
    {
        List<MerchantReviews> list = merchantReviewsService.selectMerchantReviewsList(merchantReviews);
        ExcelUtil<MerchantReviews> util = new ExcelUtil<MerchantReviews>(MerchantReviews.class);
        util.exportExcel(response, list, "商户信息审核数据");
    }

    /**
     * 获取商户信息审核详细信息
     */
    @RequiresPermissions("masterrabbit-kaixuan:merchantreviews:query")
    @GetMapping(value = "/{reviewId}")
    public AjaxResult getInfo(@PathVariable("reviewId") Long reviewId)
    {
        return success(merchantReviewsService.selectMerchantReviewsByReviewId(reviewId));
    }

    /**
     * 新增商户信息审核
     */
    @RequiresPermissions("masterrabbit-kaixuan:merchantreviews:add")
    @Log(title = "商户信息审核", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MerchantReviews merchantReviews)
    {
        return toAjax(merchantReviewsService.insertMerchantReviews(merchantReviews));
    }

    /**
     * 修改商户信息审核
     */
    @RequiresPermissions("masterrabbit-kaixuan:merchantreviews:edit")
    @Log(title = "商户信息审核", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MerchantReviews merchantReviews)
    {
        return toAjax(merchantReviewsService.updateMerchantReviews(merchantReviews));
    }

    /**
     * 删除商户信息审核
     */
    @RequiresPermissions("masterrabbit-kaixuan:merchantreviews:remove")
    @Log(title = "商户信息审核", businessType = BusinessType.DELETE)
	@DeleteMapping("/{reviewIds}")
    public AjaxResult remove(@PathVariable Long[] reviewIds)
    {
        return toAjax(merchantReviewsService.deleteMerchantReviewsByReviewIds(reviewIds));
    }

    @GetMapping("/getuserName/{userId}")
    public AjaxResult getuserName(@PathVariable("userId")int userId)
    {
    	return success( merchantReviewsService.getuaerName(userId));

    }

}
